package com.ldzy.controller;

import com.ldzy.pojo.Housing;
import com.ldzy.service.IHousingService;
import com.ldzy.utilts.RespUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@ResponseBody
@RequestMapping("/housing")
public class HousingController {
    @Resource IHousingService iHousingService;
    @PostMapping("/")
    public  List<Housing> getAllHousing(){
        System.out.println("getAllHousing");
        return  iHousingService.getAllHousing();
    }
    @PostMapping("/getByIdHousing")
    public Housing getByIdHousing(@RequestBody Housing housing){
        return  iHousingService.getByIdHousing(housing);
    }
    @PutMapping("/updateWater")
    public  void updateByHouseNumberWater(@RequestBody Housing housing){
         iHousingService.updateByHouseNumberWater(housing);
    }
    @PutMapping("/updatePower")
    public void updateByHouseNumberPower (@RequestBody Housing housing){
          iHousingService.updateByHouseNumberPower(housing);
    }
    @PostMapping("getByHouseNumberHousing")
    public  Housing getByHouseNumberHousing (@RequestBody Housing housing){
       return iHousingService.getByHouseNumberHousing(housing);
    }
    @PutMapping("updateByHouseRevise")
    public  void updateByHouseRevise(@RequestBody Housing housing){
        housing.setLive("有");
        System.out.println(housing.toString());
         iHousingService.updateByHouseRevise(housing);
    }
}
